const themes = {
  default: {
    colors: {
      frame: "#ffffff",
      toolbar: "#f8f9fa",
      tab_background_text: "#000000",
    },
  },
  green: {
    colors: {
      frame: "#E3EDCD",
      toolbar: "#E8F0DD",
      tab_background_text: "#2C3E50",
    },
  },
  brown: {
    colors: {
      frame: "#F5EEE6",
      toolbar: "#F7F2ED",
      tab_background_text: "#3E2723",
    },
  },
  blue: {
    colors: {
      frame: "#E3F2FD",
      toolbar: "#E8F5FE",
      tab_background_text: "#1A237E",
    },
  },
  gray: {
    colors: {
      frame: "#ECEFF1",
      toolbar: "#F1F3F4",
      tab_background_text: "#263238",
    },
  },
};
// 应用主题
function applyTheme(theme) {
  chrome.theme.getCurrent().then((currentTheme) => {
    chrome.theme.update(theme);
  });
}
// 初始化事件监听
document.addEventListener("DOMContentLoaded", () => {
  // 预设主题按钮点击事件
  document.querySelectorAll(".theme-btn").forEach((btn) => {
    btn.addEventListener("click", () => {
      const themeName = btn.dataset.theme;
      applyTheme(themes[themeName]);
    });
  });
  // 自定义颜色应用按钮点击事件
  document.getElementById("applyCustom").addEventListener("click", () => {
    const bgColor = document.getElementById("bgColor").value;
    const textColor = document.getElementById("textColor").value;
    const customTheme = {
      colors: {
        frame: bgColor,
        toolbar: bgColor,
        tab_background_text: textColor,
      },
    };
    applyTheme(customTheme);
  });
});
